import 'package:after_sale_plugin/common/area_code/area_model.dart';
import 'package:after_sale_plugin/pages/models/vehicle_model.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';
import 'package:safemap/safemap.dart';

class PackageDataCenter {
  /// 国家码列表
  static List<AreaModel>? cityCodeList = [];

  // 车辆信息
  static VehicleDataModel vehicleDataModel = VehicleDataModel.fromMap({});

  // 产品手册
  static bool isProductManual = false;

  // 订单id
  static String orderId = "";

  // 初始化
  PackageDataCenter.fromMap(Map<dynamic, dynamic> map) {
    SafeMap data = SafeMap(map);
    LanguageType type =
        LanguageType.getTypeByNum(data['accept_language'].toInt ?? 0) ??
            LanguageType.cn;
    AppLanguageUtil.setLanguage(type: type);
    isProductManual = data['is_manual'].boolean;
    orderId = data['order_number'].string ?? "";
    vehicleDataModel = VehicleDataModel.fromMap(data['vehicle_data'].map ?? {});
    // if (vehicleDataModel.sn == null) throw Exception('vehicleDataModel.sn 不能为空');
  }
}
